package com.learn2;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Main {
    public static void main(String[] args) {
        // 1. 声明Spring 容器，并加载配置类
        AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(AopConfig.class);

        // 运行之前拦截
        DemoMethodService methodService = ac.getBean(DemoMethodService.class);
        methodService.add();
        System.out.println("================================");

        // 运行过后拦截
        DemoAnnotationService annotationService = ac.getBean(DemoAnnotationService.class);
        annotationService.add();
        System.out.println("================================");

        // 环绕通知
        AroundMethodService aroundMethodService = ac.getBean(AroundMethodService.class);
        aroundMethodService.add();
        ac.close();
    }
}
